// 复选框组件 可以全选
<template>
  <div id="checkboxX">
    <el-checkbox
      :indeterminate="isIndeterminate"
      v-model="checkAll"
      @change="handleCheckAllChange"
      style="float:left"
    >全选</el-checkbox>
    <div style="margin: 15px 0;"></div>
    <el-checkbox-group v-model="checkedOptions" @change="handlecheckedOptionsChange">
      <el-checkbox v-for="item in optionslist" :label="item.key" :key="item.key" :value="item.key">{{item.label}}</el-checkbox>
    </el-checkbox-group>
  </div>
</template>

<script>

  const options = ["建设单位","设计单位","勘察总体","勘察单位"];
   

  export default {
    name: "checkboxX",

    props: {
      alloptions: []
      // configs: {
      //   type: Object,
      //   default() {
      //     return {
      //       active: 0,
      //       processstatus: "",
      //       data:{
      //         title: '',
      //         description: ''
      //       }
      //     };
      //   }
      // }
    },
    data() {
        return {
          checkAll: false,
          checkedOptions: [],
          optionslist: [
            { label: "建设单位", key: 0 },
            { label: "设计单位", key: 1 },
            { label: "勘察总体", key: 2 },
            { label: "勘察单位", key: 3 }
          ],
          isIndeterminate: true
        };
    },

    methods: {
        handleCheckAllChange(val) {
          console.log(val);
          
          this.checkedOptions = [0,1,2,3] ? options : [];
          this.isIndeterminate = false;
          
        },
        handlecheckedOptionsChange(value) {

          let checkedCount = value.length;
          this.checkAll = checkedCount === this.optionslist.length;
          this.isIndeterminate = checkedCount > 0 && checkedCount < this.optionslist.length;
          console.log(this.checkedOptions);
        } 
    }
  };
</script>

<style lang="less">
</style>
